home *** CD-ROM | disk | FTP | other *** search
- /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Copyright (C) 1994, by WATCOM International Inc. All rights %
- % reserved. No part of this software may be reproduced or %
- % used in any form or by any means - graphic, electronic or %
- % mechanical, including photocopying, recording, taping or %
- % information storage and retrieval systems - except with the %
- % written permission of WATCOM International Inc. %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- */
-
- /*************************************************************************
- *
- * WOleServerObject -- Ole Server Object class
- *
- *
- * Events:
- *
- * QueryInterface -- QueryInterface event
- *
- *************************************************************************/
-
- #ifndef _WOLESOBJ_HPP_INCLUDED
- #define _WOLESOBJ_HPP_INCLUDED
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- #ifndef _WOLETYPE_HPP_INCLUDED
- # include "woletype.hpp"
- #endif
- #ifndef _WOLEAUTO_HPP_INCLUDED
- # include "woleauto.hpp"
- #endif
- #ifndef _WSTRING_HPP_INCLUDED
- # include "wstring.hpp"
- #endif
- #ifndef _WRECT_HPP_INCLUDED
- # include "wrect.hpp"
- #endif
- #ifndef _WPALETTE_HPP_INCLUDED
- # include "wpalette.hpp"
- #endif
-
- #define OPTIMA_COMPONENT_KEY_STR "OptimaOleComponent"
-
- // forward class declarations
- class WCMCLASS WApplication;
- class WCMCLASS WOleClassManager;
- class WCMCLASS WOleServerObject;
- class WCMCLASS WOleServerObjectListEntry;
- class WCMCLASS WOleServerObjectRegistryData;
- class WCMCLASS WOleServerObject_IUnk;
- class WCMCLASS wllist_header;
- class WCMCLASS WOleInterfaceFamily;
- class IOleClientSite;
-
- typedef WOleServerObject * WCMDEF (*pfnOleSvrCreateInst)( WPIUnknown pUnkOuter );
- typedef WBool WCMDEF (*pfnOleSvrIsEqualClassID)( const WCLSID & clsid );
-
- struct WOleServerObjectRegistryDataBlock {
- WChar *_progID;
- WChar *_viProgID;
- WChar *_appFullName;
- WChar *_appShortName;
- WBool _insertable;
- WBool _isOleControl;
- WInt _versionMajor;
- WInt _versionMinor;
- };
-
- class WCMCLASS WOleServerObjectRegistryData {
- public:
- WOleServerObjectRegistryData( const WCLSID & clsid, WOleServerObjectRegistryDataBlock * );
- ~WOleServerObjectRegistryData( void );
-
- // Self Registration
- WBool Register( WApplication *application );
- WBool Unregister( WApplication *application );
-
- WCLSID _classID;
- WOleServerObjectRegistryDataBlock *_registryDataBlock;
-
- static WOleServerObjectRegistryData *Head;
- WOleServerObjectRegistryData *next;
- };
-
- // QueryInterface event data structure
- struct WQueryInterfaceEventData : public WEventData {
- WCLSID wclsid;
- WPIUnknown pIUnknown;
- };
-
- // the following is definitions of WOleServerObject
-
- class WCMCLASS WOleServerObject : public WEventGenerator {
- WDeclareSubclass( WOleServerObject, WEventGenerator );
-
- friend class WOleServerObject_IUnk;
-
- public:
-
- /**********************************************************
- * Constructors and Destructors
- *********************************************************/
-
- WOleServerObject();
- virtual ~WOleServerObject();
-
- WBool Create( WOleClassManager * );
- WBool Destroy( void );
-
- public:
-
- /**************************************************************
- * Properties
- **************************************************************/
-
- // Prog ID
- WString GetProgID( void ) const;
-
- // Version Independent Prog ID
- WString GetVersionIndependentProgID( void ) const;
-
- // Version Major
- WInt GetVersionMajor( void ) const;
-
- // Version Minor
- WInt GetVersionMinor( void ) const;
-
- // Application Full Name
- WString GetApplicationFullName( void ) const;
-
- // Application Short Name ( 15 chars max )
- WString GetApplicationShortName( void ) const;
-
- // IsInsertable
- WBool GetIsInsertable( void ) const;
-
- // IsOleControl
- WBool GetIsOleControl( void ) const;
-
- // IUknown interface
- WPIUnknown GetIUnknown( WBool addRef=TRUE ) const;
-
- // Number of InterfaceFamilies
- WInt GetNumInterfaceFamilies( void ) const;
-
- // Client Site pointer
- IOleClientSite *GetClientSite( void );
- void SetClientSite( IOleClientSite * );
-
- // Ambient Properties
- WBool GetAmbientProperty( WDispID, WVariant * );
-
- // Extents
- WBool SetExtent( WDWord, WRect );
- WRect *GetExtent( WDWord );
-
- // Acts Like Button Property
- void SetActsLikeButton( WBool set = TRUE );
- WBool GetActsLikeButton( void );
-
- // Acts Like label Property
- void SetActsLikeLabel( WBool set = TRUE );
- WBool GetActsLikeLabel( void );
-
- // Alignable property
- void SetAlignable( WBool set = TRUE );
- WBool GetAlignable( void );
-
- // Container Name
- WBool SetContainerName( WString );
- WString GetContainerName( void );
-
- // Application Name
- WBool SetApplicationName( WString );
- WString GetApplicationName( void );
-
- // Colour Scheme
- WBool SetColorScheme( WColorArray );
- WColorArray GetColorScheme( void );
-
- /**************************************************************
- * Static Methods
- **************************************************************/
-
- // Self Registration
- static WBool Register( WApplication *application );
- static WBool Unregister( WApplication *application );
-
- /**************************************************************
- * Methods
- **************************************************************/
-
- // Add an Interface Family
- WBool AddInterfaceFamily( WOleInterfaceFamily *interfaceFamily );
-
- // Specify RegistryData
- WBool SetRegistryData( WOleServerObjectRegistryData * );
- WOleServerObjectRegistryData *GetRegistryData( void ) const;
-
- // Reference counting
- WULong AddRef( void );
- WULong Release( void );
-
- // Get the servers WCLSID
- virtual WCLSID OleClassID( void );
-
- /**************************************************************
- * Item Properties
- **************************************************************/
-
- WOleInterfaceFamily *GetInterfaceFamily( WInt index ) const;
- WOleInterfaceFamily *GetInterfaceFamily( const WString & className ) const;
-
- /**************************************************************
- * Internal Methods
- **************************************************************/
-
- // Aggregating IUnknown
- WBool SetUnkOuter( WPIUnknown pUnkOuter );
- WPIUnknown GetUnkOuter( void ) const;
-
- protected:
-
- WBool QueryInterfaceFamilies( const WCLSID & clsid, void **iface );
-
- /**********************************************************
- * Data Members
- *********************************************************/
-
- protected:
- WULong _refCount;
- WPIUnknown _pUnkOuter;
- WOleServerObject_IUnk *_iunknown;
- wllist_header *_ifamilyList;
- WOleClassManager *_classManager;
- WOleServerObjectRegistryData *_registryData;
- IOleClientSite *_pClientSite;
- WRect *_pContentExtent;
- WRect *_pIconicExtent;
- WBool _actsLikeLabel;
- WBool _actsLikeButton;
- WBool _alignable;
- WString _containerName;
- WString _appName;
- WColorArray _palette;
-
- };
-
- class WCMCLASS WOleServerObjectListEntry {
- public:
- WOleServerObjectListEntry( pfnOleSvrCreateInst pfn, const WCLSID & clsid );
- ~WOleServerObjectListEntry( void );
-
- pfnOleSvrCreateInst fnCreateInst;
- WCLSID classID;
- static WOleServerObjectListEntry *Head;
- WOleServerObjectListEntry *next;
- };
-
- #define WOleDeclareServerObjectClassID() \
- public: \
- static WCLSID _oleClassID; \
- virtual WCLSID OleClassID( void ) { return( _oleClassID ); };
-
- #define WOleDefineServerObjectClassID( c, c_id ) \
- WCLSID c::_oleClassID = c_id;
-
- #define WOleDeclareServerObject( c, c_id ) \
- WOleDeclareServerObjectClassID(); \
- protected: \
- WOleServerObjectListEntry *_serverObjectListEntry; \
- public: \
- static WOleServerObject *CreateInstance( WPIUnknown pUnkOuter );
-
- #define WOleDefineServerObject( c, c_id, rdb ) \
- WOleDefineServerObjectClassID( c, c_id ); \
- static WOleServerObjectRegistryData _WOleSvrRegistryData( c_id, &rdb );\
- static WOleServerObjectListEntry _WOleSvrListEntry( (pfnOleSvrCreateInst)c::CreateInstance, c_id );\
- static WOleServerObject * \
- c::CreateInstance( WPIUnknown pUnkOuter ) { \
- c *obj = new c(); \
- if( obj ) { \
- obj->SetUnkOuter( pUnkOuter ); \
- obj->SetRegistryData( &_WOleSvrRegistryData ); \
- } \
- return( obj ); \
- }
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WOLESOBJ_HPP_INCLUDED
-
-